package com.codeforces.contest.c302;

import java.util.Scanner;

public class _302A {

	static Scanner scanner = new Scanner(System.in);
	static int n, m, l, r, pos, neg, num, mi;

	public static void main(String[] args) {
		n = scanner.nextInt();
		m = scanner.nextInt();
		pos = neg = 0;
		for (int i=1;i<=n;++i) {
			num = scanner.nextInt();
			if (num == 1) {
				pos++;
			}
			else {
				neg++;
			}
		}
		
		mi = pos < neg ? pos : neg;
		
		for (int i=0;i<m;++i) { 
			l = scanner.nextInt();
			r = scanner.nextInt();
			if ((r - l + 1) % 2 == 0) {
				if ((r - l + 1) / 2 <= mi) {
					System.out.println(1);
				}
				else {
					System.out.println(0);
				}
			}
			else {
				System.out.println(0);
			}
		}
	}

}
